package com.wyl.servlet

import javax.servlet.annotation.WebServlet
import javax.servlet.http.Cookie
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
 * 清除cookie01所设置的cookie
 */
@WebServlet("/cookie02")
class CookieServlet02 : HttpServlet() {
    override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
        req.characterEncoding = "utf-8"
        resp.contentType = "text/html;charset=UTF-8"

        val cookie = Cookie("time", "")
        cookie.maxAge = 0
        resp.addCookie(cookie)
    }

    override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
        doPost(req, resp)
    }
}